//
//  SINACircularBeadUtils.m
//  sinashebao
//
//  Created by  androidlongs on 2018/1/2.
//  Copyright © 2018年  androidlongs. All rights reserved.
// 圆角工具类

#import "SINACircularBeadUtils.h"

@implementation SINACircularBeadUtils




+(void)makeCircularBead:(NSInteger)bead andView:(UIView *)view{
    [self makeCircularBead:bead andView:view andIsSetBackground:NO];
}

+(void)makeCircularDefaultBead:(UIView *)view{
    [self makeCircularBead:5 andView:view andIsSetBackground:NO];
}

+(void)makeCircularBead:(NSInteger)bead andView:(UIView *)view andIsSetBackground:(BOOL)isSetBg{
    
    if (isSetBg) {
        
        [self makeCircularBead:bead andView:view andIsSetBackgroundColor: [UIColor colorWithRed:0/255 green:198.0/255 blue:174.0/255 alpha:0.8f]];
    }else{
        [self makeCircularBead:bead andView:view andIsSetBackgroundColor: nil];
    }
    
}
+(void)makeCircularBead:(NSInteger)bead andView:(UIView *)view andIsSetBackgroundColor:(UIColor *)color{
    //设置lable的圆角显示
    view.layer.cornerRadius =bead;
    //设置lable的边框 宽度为1
    view.layer.borderWidth=0;
    //设置lable的边框颜色
    view.layer.borderColor=[UIColor redColor].CGColor;
    //设置 显示大小范围为 border内容范围中
    view.clipsToBounds = YES;
    
    if (color!=nil) {
        [view setBackgroundColor: color];
    }
}

+(void)makeCircularView:(UIView *)view{
    //定义绘制曲线路径
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:UIRectCornerAllCorners cornerRadii:view.bounds.size];
    //初始化
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc]init];
    //设置大小
    maskLayer.frame = view.bounds;
    //设置绘制图形曲线
    maskLayer.path = maskPath.CGPath;
    //设置layer mask
    view.layer.mask = maskLayer;
}
+(void)makeCircularView:(UIView *)view :(NSInteger)corners{
    //定义绘制曲线路径
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:UIRectCornerAllCorners cornerRadii:CGSizeMake(view.bounds.size.width-corners*2, view.bounds.size.height)];
    //初始化
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc]init];
    //设置大小
    maskLayer.frame = view.bounds;
    //设置绘制图形曲线
    maskLayer.path = maskPath.CGPath;
    //设置layer mask
    view.layer.mask = maskLayer;
}



+(void)makeBorder:(UIView *)view andWithBorderWidth:(NSInteger)borderWidth andBorderRadius:(NSInteger)borderRadius andBorderColor:(UIColor *)borderColor{
    view.layer.masksToBounds = YES;
    view.layer.cornerRadius = borderRadius;
    view.layer.borderWidth = borderWidth;
    view.layer.borderColor = [borderColor CGColor];
    
}


@end
